<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    .box1 {
      position: absolute;
      width: 700px;
      height: 700px;
      background-color: yellow;
    }
    .box2 {
      position: absolute;
      width: 100px;
      height: 100px;
      background-color: skyblue;
    }
  </style>
  <body>
    <div class="box1"></div>
    <div class="box2"></div>

    <script>
      var box1 = document.querySelector(".box1");
      var box2 = document.querySelector(".box2");

      document.onmousemove = function () {
        var left = event.pageX;
        var top = event.pageY;

        box2.style.left = left + "px";
        box2.style.top = top + "px";
      };
      box1.onmousemove = function () {
        event.cancelBubble = true;
      };
    </script>
  </body>
</html>
